
package com.itheima.easy.controller;

import com.itheima.easy.base.AjaxResult;
import com.itheima.easy.base.PageResponse;
import com.itheima.easy.service.ElderService;
import com.itheima.easy.vo.retreat.ElderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 客户老人关联 Controller
 */
@RestController
@RequestMapping("/elder")
@Api(tags = "老人")
public class ElderController {

    @Resource
    private ElderService elderService;

    /**
     * 列表
     */
    @GetMapping("/selectList")
    @ApiOperation(value = "列表")
    public AjaxResult selectList() {
        List<ElderVo> elderVos = elderService.selectList();
        return AjaxResult.success(elderVos);
    }


    /**
     * 选择老人列表
     */
    @GetMapping("/selectListByPage")
    @ApiOperation(value = "选择老人列表")
    public AjaxResult selectListByPage(@RequestParam(required = false) String name,
                                       @RequestParam(required = false) String idCardNo,
                                       @RequestParam(required = false, defaultValue = "1") Integer pageNum,
                                       @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
        PageResponse pageResponse = elderService.selectListByPage(name,idCardNo,pageNum,pageSize);
        return AjaxResult.success(pageResponse);
    }

}


